var http=require('http');
var fs=require('fs');


http.createServer(function(require,response){
	
	response.writeHead(200,{'Content-Type':'text/html;charset="utf-8"'})

	var file=require.url.substr(1);
	console.log('准备写入文件')
	fs.writeFile('2.txt',file,function(err){
		if(err){
			return console.log(err);
		}
		console.log('写入文件成功')
		console.log('准备读取文件')
		fs.readFile('2.txt',function(err,data){
		
			console.log('读取文件内容：'+decodeURI(data))
			
			response.write(decodeURI(data))
			
			response.end();
		})
		
	})
	
}).listen(6064)

console.log('服务已打开！！')